package src.automouser;

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author bartnikj
 */
public class autoMouserRobot {
    private Robot robot;
    public autoMouserRobot() throws AWTException{
        robot = new Robot();
    }

    public void mouseClick(){
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.delay(10);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
    }

    public void mouseMove(int x, int y){
        robot.mouseMove(x,y);
    }

    public void moveAndClick(int x, int y){
        this.mouseMove(x, y);
        this.wait(50);
        this.mouseClick();
    }
    
    public void mouseMultiClick(int clicks){
        for(int i=1;i<=clicks;i++){
            this.mouseClick();
            this.wait(200);
        }
    }

    public void mouseRobot(int x, int y, int clicks){
        this.mouseMove(x, y);
        this.wait(100);
        for(int i=1;i<=clicks;i++){
            this.mouseClick();
            this.wait(200);
        }
    }

    public void moveAndDoubleClick(int x, int y){
        this.mouseMove(x, y);
        this.wait(100);
        this.mouseClick();
        this.wait(50);
        this.mouseClick();
    }

    public void wait(int ms){
        try {
            Thread.sleep(ms);
        } catch (InterruptedException ex) {
            Logger.getLogger(autoMouserRobot.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}
